package com.sh.intermediate_control;

import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

public class AlertDialogActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tv_alert;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_alert_dialog);
        findViewById(R.id.btn_alter).setOnClickListener(this);
        tv_alert = findViewById(R.id.tv_alert);
    }

    @Override
    public void onClick(View v) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("尊敬的用户");
        builder.setMessage("您真的要卸载吗？");

        builder.setPositiveButton("残忍卸载", (dialog, which) -> {
            tv_alert.setText("ok,卸载成功");

        });

        builder.setNegativeButton("我再想想", (dialog, which) -> {
            tv_alert.setText("继续使用");
        });

        AlertDialog alertDialog = builder.create();
        alertDialog.show();

    }
}